package com.ruslan.magaz.domain;
// default package
// Generated 28.09.2014 13:25:18 by Hibernate Tools 3.4.0.CR1

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ruslan.magaz.web.validation.GotSome;
import com.ruslan.magaz.web.validation.ValidCount;


/**
 * Anorder generated by hbm2java
 */
@Entity
@Table(name = "anorder", catalog = "eshop")
public class Order implements java.io.Serializable {

	private int orderId;
	private Customer customer;
	private Integer discount;
	private List<OrderStatus> orderStatuses = new ArrayList<OrderStatus>();
	@ValidCount
	@GotSome
	private List<OrderedItem> orderedItems = new ArrayList<OrderedItem>();

	public Order() {
	}

	public Order(int orderId, Customer customer) {
		this.orderId = orderId;
		this.customer = customer;
	}

	public Order(int orderId, Customer customer,
			Integer discount, List<OrderStatus> orderStatuses, List<OrderedItem> orderedItems) {
		this.orderId = orderId;
		this.customer = customer;
		this.discount = discount;
		this.orderStatuses = orderStatuses;
		this.orderedItems = orderedItems;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "Order_id", unique = true, nullable = false)
	public int getOrderId() {
		return this.orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "Customer_id", nullable = false)
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}


	@Column(name = "Discount")
	public Integer getDiscount() {
		return this.discount;
	}

	public void setDiscount(Integer discount) {
		this.discount = discount;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order", cascade = CascadeType.ALL)
	public List<OrderStatus> getOrderStatuses() {
		return this.orderStatuses;
	}

	public void setOrderStatuses(List<OrderStatus> orderStatuses) {
		this.orderStatuses = orderStatuses;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order", cascade = CascadeType.ALL)
	public List<OrderedItem> getOrderedItems() {
		return this.orderedItems;
	}

	public void setOrderedItems(List<OrderedItem> orderedItems) {
		this.orderedItems = orderedItems;
	}
}
